package mock.utility;

import java.io.Serializable;
import java.sql.Connection;
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Utility implements Serializable {

    /**
     * create connection to database
     * @return
     */
    public Connection createConnection() {
		Connection con = null;
		try {
			Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
			try {
				con = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=ATMSystem", "sa", "1234567890");
				return con;
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				return null;
			}
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

    /**
     * take the date of the system in that moment 
     * @return
     */
    public Date getCurrentDate() {
        java.util.Date utilDate = new java.util.Date();
        java.sql.Date sqlDate = new Date(utilDate.getTime());
        return sqlDate;
    }

}
